quest pet_system begin
	state start begin
		function get_pet_info(itemVnum)
			pet_info_map = {
				[53001] = {34001, " - "..mob_name(34001).." ", 1},
				[53002] = {34002, " - "..mob_name(34002).." ", 1},
				[53003] = {34003, " - "..mob_name(34003).." ", 1},
				[53005] = {34004, " - "..mob_name(34004).." ", 1},
				[53006] = {34009, " - "..mob_name(34009).." ", 1},
				[53007] = {34010, " - "..mob_name(34010).." ", 1},
				[53008] = {34011, " - "..mob_name(34011).." ", 1},
				[53009] = {34012, " - "..mob_name(34012).." ", 1},
				[53010] = {34008, " - "..mob_name(34008).." ", 1},
				[53011] = {34007, " - "..mob_name(34007).." ", 1},
				[53012] = {34005, " - "..mob_name(34005).." ", 1},
				[53013] = {34006, " - "..mob_name(34006).." ", 1},
				[53014] = {34013, " - "..mob_name(34013).." ", 1},
				[53015] = {34014, " - "..mob_name(34014).." ", 1},
				[53016] = {34015, " - "..mob_name(34015).." ", 1},
				[53017] = {34016, " - "..mob_name(34016).." ", 1},
				[53018] = {34020, " - "..mob_name(34020).." ", 1},
				[53019] = {34019, " - "..mob_name(34019).." ", 1},
				[53020] = {34017, " - "..mob_name(34017).." ", 1},
				[53021] = {34018, " - "..mob_name(34018).." ", 1},
				[53022] = {34021, " - "..mob_name(34021).." ", 1},
				[53023] = {34022, " - "..mob_name(34022).." ", 1},
				[53024] = {34023, " - "..mob_name(34023).." ", 1},
				[53025] = {34024, " - "..mob_name(34024).." ", 1},
				[53026] = {34025, " - "..mob_name(34025).." ", 1},
				[53218] = {34023, " - "..mob_name(34023).." ", 1},
				[53219] = {34023, " - "..mob_name(34023).." ", 1},
				[53220] = {34024, " - "..mob_name(34024).." ", 1},
				[53221] = {34024, " - "..mob_name(34024).." ", 1},
				[53222] = {34026, " - "..mob_name(34026).." ", 1},
				[53223] = {34027, " - "..mob_name(34027).." ", 1},
				[53224] = {34028, " - "..mob_name(34028).." ", 1},
				[53225] = {34029, " - "..mob_name(34029).." ", 1},
				[53226] = {34030, " - "..mob_name(34030).." ", 1},
				[53227] = {34031, " - "..mob_name(34031).." ", 1},
				[53228] = {34033, " - "..mob_name(34033).." ", 1},
				[53229] = {34032, " - "..mob_name(34032).." ", 1},
				[53230] = {34034, " - "..mob_name(34034).." ", 1},
				[53231] = {34035, " - "..mob_name(34035).." ", 1},
				[53232] = {34039, " - "..mob_name(34039).." ", 1},
				[53233] = {34055, " - "..mob_name(34055).." ", 1},
				[53234] = {34056, " - "..mob_name(34056).." ", 1},
				[53235] = {34055, " - "..mob_name(34055).." ", 1},
				[53236] = {34058, " - "..mob_name(34058).." ", 1},
				[53237] = {34059, " - "..mob_name(34059).." ", 1},
				[53238] = {34058, " - "..mob_name(34058).." ", 1},
				[53239] = {34059, " - "..mob_name(34059).." ", 1},
				[53240] = {34063, " - "..mob_name(34063).." ", 1},
				[53241] = {34062, " - "..mob_name(34062).." ", 1},
				[53242] = {34066, " - "..mob_name(34066).." ", 1},
				[53243] = {34066, " - "..mob_name(34066).." ", 1},
				[53244] = {34067, " - "..mob_name(34067).." ", 1},
				[53245] = {34068, " - "..mob_name(34068).." ", 1},
				[53246] = {34069, " - "..mob_name(34069).." ", 1},
				[53247] = {34070, " - "..mob_name(34070).." ", 1},
				[53248] = {34071, " - "..mob_name(34071).." ", 1},
				[53249] = {34072, " - "..mob_name(34072).." ", 1},
				[53250] = {34085, " - "..mob_name(34085).." ", 1},
				[53251] = {34084, " - "..mob_name(34084).." ", 1},
				[53253] = {34086, " - "..mob_name(34086).." ", 1},
				[53254] = {34087, " - "..mob_name(34087).." ", 1},
				[53255] = {34088, " - "..mob_name(34088).." ", 1},
				[53256] = {34066, " - "..mob_name(34066).." ", 1},
				[53258] = {34090, " - "..mob_name(34090).." ", 1},
				[53259] = {34091, " - "..mob_name(34091).." ", 1},
				[53260] = {34092, " - "..mob_name(34092).." ", 1},
				[53261] = {34093, " - "..mob_name(34093).." ", 1},
				[53262] = {34094, " - "..mob_name(34094).." ", 1},
				[53263] = {34095, " - "..mob_name(34095).." ", 1},
				[53264] = {34096, " - "..mob_name(34096).." ", 1},
				[53265] = {34097, " - "..mob_name(34097).." ", 1},
				[53266] = {34098, " - "..mob_name(34098).." ", 1},
				[53267] = {34099, " - "..mob_name(34099).." ", 1},
				[53268] = {34100, " - "..mob_name(34100).." ", 1},
				[53269] = {34101, " - "..mob_name(34101).." ", 1},
				[53270] = {34102, " - "..mob_name(34102).." ", 1},
				[53271] = {34103, " - "..mob_name(34103).." ", 1},
				[53272] = {34104, " - "..mob_name(34104).." ", 1},
				[53273] = {34105, " - "..mob_name(34105).." ", 1},
				[53274] = {34106, " - "..mob_name(34106).." ", 1},
				[53275] = {34107, " - "..mob_name(34107).." ", 1},
				[53276] = {34108, " - "..mob_name(34108).." ", 1},
				[53257] = {34089, " - "..mob_name(34089).." ", 1},
				[53277] = {34109, " - "..mob_name(34109).." ", 1},
				[53278] = {34110, " - "..mob_name(34110).." ", 1},
				[53279] = {34111, " - "..mob_name(34111).." ", 1},
				[53280] = {34112, " - "..mob_name(34112).." ", 1},
				[53281] = {34113, " - "..mob_name(34113).." ", 1},
				[53288] = {34120, " - "..mob_name(34120).." ", 1},
				[53289] = {34121, " - "..mob_name(34121).." ", 1},
				[53282] = {34114, " - "..mob_name(34114).." ", 1},
				[53283] = {34115, " - "..mob_name(34115).." ", 1},
				[53284] = {34116, " - "..mob_name(34116).." ", 1},
				[53285] = {34117, " - "..mob_name(34117).." ", 1},
				[53286] = {34118, " - "..mob_name(34118).." ", 1},
				[53287] = {34119, " - "..mob_name(34119).." ", 1},
				[53290] = {34124, " - "..mob_name(34124).." ", 1},
				[53291] = {34125, " - "..mob_name(34125).." ", 1},
				[53292] = {34126, " - "..mob_name(34126).." ", 1},
				[53293] = {34127, " - "..mob_name(34127).." ", 1},
				[53294] = {34128, " - "..mob_name(34128).." ", 1},
				[53295] = {34129, " - "..mob_name(34129).." ", 1},
				[53296] = {34130, " - "..mob_name(34130).." ", 1},
				[53297] = {34131, " - "..mob_name(34131).." ", 1},
				[53298] = {34132, " - "..mob_name(34132).." ", 1},
				[53299] = {34133, " - "..mob_name(34133).." ", 1},
				[53300] = {34134, " - "..mob_name(34134).." ", 1},
			}

			itemVnum = tonumber(itemVnum)
			return pet_info_map[itemVnum]
		end

		function get_spawn_effect_file(idx)
			effect_table = {
				[0] = nil,
				[1] = "d:\\\\ymir work\\\\effect\\\\etc\\\\appear_die\\\\monster_appear.mse",
			}
			return effect_table[idx]
		end

		when
			53001.use or
			53002.use or
			53003.use or
			53005.use or 53006.use or
			53007.use or
			53008.use or 53009.use or
			53010.use or 53011.use or 53012.use or 53013.use or
			53014.use or 53015.use or
			53016.use or 53017.use or
			53018.use or 53019.use or 53020.use or 53021.use or
			53022.use or 53023.use or
			53024.use or 53025.use or
			53026.use or
			53218.use or 53219.use or 53220.use or 53221.use or
			53222.use or 53223.use or
			53224.use or 53225.use or
			53226.use or 53227.use or
			53228.use or 53229.use or
			53230.use or 53231.use or
			53232.use or
			53233.use or 53234.use or 53235.use or
			53236.use or 53237.use or 53238.use or 53239.use or
			53240.use or 53241.use or
			53242.use or 53243.use or
			53244.use or 53245.use or 53246.use or
			53247.use or 53248.use or 53249.use or
			53250.use or 53251.use or
			53253.use or 53254.use or 53255.use or
			53256.use or
			53258.use or 53259.use or
			53260.use or 53261.use or 53262.use or
			53263.use or 53264.use or
			53265.use or 53266.use or 53267.use or
			53268.use or 53269.use or 53270.use or
			53271.use or 53272.use or 53273.use or
			53274.use or 53275.use or 53276.use or
			53257.use or
			53277.use or 53278.use or 53279.use or 53280.use or 53281.use or
			53288.use or 53289.use or
			53282.use or 53283.use or 53284.use or
			53285.use or 53286.use or 53287.use or
			53296.use or 53297.use or 53298.use or
			53290.use or 53291.use or 53292.use or 53293.use or 53294.use or 53295.use or
			53299.use or 53300.use
		begin
			local pet_info = pet_system.get_pet_info(item.get_vnum())
			if nil != pet_info then
				local mobVnum = pet_info[1]
				local petName = pet_info[2]
				local spawn_effect_file_name = pet_system.get_spawn_effect_file(pet_info[3])

				if true == pet.is_summon(mobVnum) then
					if spawn_effect_file_name != nil then
						pet.spawn_effect(mobVnum, "d:\\\\ymir work\\\\effect\\\\etc\\\\appear_die\\\\monster_die.mse")
					end

					pet.unsummon(mobVnum)
				else
					if pet.count_summoned() < 1 then
						pet.summon(mobVnum, petName, false)
					else
						syschat("Vous ne pouvez pas invoquer votre familier pour le moment.")
					end

					if spawn_effect_file_name != nil then
						pet.spawn_effect(mobVnum, spawn_effect_file_name)
					end
				end
			end
		end
	end
end
